<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>setShenHeAuth</title>
    <link rel="stylesheet" href="../../../static/layer/css/layui.css" media="all"/>
    <style>
        .layui-form-label {
            width: 150px;
        }
        .layui-center {
            width: 100%;
            text-align: center;
        }
    </style>
</head>
<body>
<div style="padding: 20px;">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">开启合同审核等级：</label>
            <div class="layui-input-block">
                <input type="radio" name="CONTRACT_AUTH" value="1" title="1级审核" checked="">
                <input type="radio" name="CONTRACT_AUTH" value="2" title="2级审核">
                <input type="radio" name="CONTRACT_AUTH" value="3" title="3级审核">
                <input type="radio" name="CONTRACT_AUTH" value="4" title="4级审核">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开启账单审核等级：</label>
            <div class="layui-input-block">
                <input type="radio" name="BILL_AUTH" value="1" title="1级审核" checked="">
                <input type="radio" name="BILL_AUTH" value="2" title="2级审核">
                <input type="radio" name="BILL_AUTH" value="3" title="3级审核">
                <input type="radio" name="BILL_AUTH" value="4" title="4级审核">
            </div>
        </div>
        <div class="layui-center">
            <button class="layui-btn" lay-submit="" lay-filter="submit">保存</button>
        </div>
    </form>
</div>
<script type="text/javascript" src="../../../static/js/common/queryUtils.js"></script>
<script type="text/javascript" src="../../../static/layer/layui.js"></script>
<script>
    layui.use(['jquery', 'form'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;

        var active = {
            // 初始化权限列表
            initAuth: function () {
                $.ajax({
                    url: "/shsRole/shenHeAuth",
                    data: null,
                    dataType: "json",
                    type: "post",
                    async: false,
                    success: function (res) {
                        if (res.errcode === "0") {
                          // console.log(res.data);
                            if (!!res.data) {
                                $("input[name='CONTRACT_AUTH'][value='" + res.data.CONTRACT_AUTH + "']").attr("checked", true);
                                $("input[name='BILL_AUTH'][value='" + res.data.BILL_AUTH + "']").attr("checked", true);
                                form.render();
                            }
                        } else if (res.errcode === "1") {
                            layer.msg(res.errmsg, function () {
                            });
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        console.error(XMLHttpRequest.status);
                        console.error(XMLHttpRequest.readyState);
                        console.error(textStatus);
                    }
                });
            }
        };

        active.initAuth();

        //监听提交
        form.on('submit(submit)', function (data) {
            $.ajax({
                url: "/shsRole/editShenHeAuth",
                data: data.field,
                dataType: "json",
                type: "post",
                async: false,
                success: function (res) {
                    if (res.errcode === "0") {
                        // var i = parent.layer.getFrameIndex(window.name);
                        // parent.layer.close(i);  // 关闭修改商圈页面
                        parent.layer.msg("设置成功", {offset: '150px'});   // 父页面弹出修改成功
                    } else if (res.errcode === "1") {
                        layer.msg(res.errmsg, function () {
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.error(XMLHttpRequest.status);
                    console.error(XMLHttpRequest.readyState);
                    console.error(textStatus);
                }
            });
            return false;
        });

    });
</script>
</body>
</html>